from django.db import models


# Create your models here.


class TypeModel(models.Model):
    title = models.CharField(max_length=20)

    class Meta:
        verbose_name = '广告类型'
        verbose_name_plural = verbose_name

    def __str__(self):
        return self.title


class AdvModel(models.Model):
    type = models.ForeignKey(TypeModel, on_delete=models.CASCADE)
    title = models.CharField(max_length=20)
    level = models.CharField(max_length=5, choices=((1, '一级'), (2, '二级'), (3, '三级')), null=True, blank=True)
    cate = models.ForeignKey('self', on_delete=models.SET_NULL, null=True, blank=True)
    pic = models.ImageField(upload_to='adv/', null=True, blank=True)
    url = models.CharField(max_length=200, null=True, blank=True)

    class Meta:
        verbose_name = '广告分类'
        verbose_name_plural = verbose_name

    def __str__(self):
        return self.title
